package com.ccrfid.rmc6.repository.alarm;

import com.ccrfid.rmc6.entity.alarm.AlarmRuleEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface AlarmRuleRepository extends Repository<AlarmRuleEntity, Long> {
    //
    AlarmRuleEntity getById(Long id);
    //
    Boolean existsById(Long id);
    //
    AlarmRuleEntity save(AlarmRuleEntity entity);
    //
    void deleteById(Long id);
    //
    List<AlarmRuleEntity> getAllBy();
    //
    List<AlarmRuleEntity> getAllByLocationId(Long locationId);
    //
    List<AlarmRuleEntity> getAllByAlarmTypeIn(List<Integer> alarmTypeList);
    //
    List<AlarmRuleEntity> getAllByAlarmTypeNotIn(List<Integer> alarmTypeList);

    Boolean existsByAlarmType(Integer alarmType);

    List<AlarmRuleEntity> getAllByAlarmType(Integer alarmType);

    void deleteAllByAlarmType(Integer alarmType);

    @Query(nativeQuery = true, value = "select distinct(alarm_rule_name) from alarm_rule where alarm_rule_name is not null")
    List<String> getDistinctByAlarmRuleName();
}
